//
//  CustomTableViewCell.m
//  MicroBlog
//
//  Created by cocoazxj@163.com on 15/3/29.
//  Copyright (c) 2015年 handcool. All rights reserved.
//

#import "CustomTableViewCell.h"
@interface CustomTableViewCell()
@property (nonatomic, strong) IBOutlet UIImageView *iv_icon;
@property (nonatomic, strong) IBOutlet UILabel *lb_name;
@property (nonatomic, strong) IBOutlet UIImageView *iv_vip;
@property (nonatomic, strong) IBOutlet UILabel *lb_content;
@property (nonatomic, strong) IBOutlet UIImageView *iv_picture;
@end
@implementation CustomTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 60, 60)];
        icon.backgroundColor = [UIColor redColor];
        self.iv_icon = icon;
        [self.contentView addSubview:icon];
        
        UILabel *name = [[UILabel alloc] init];
        self.lb_name = name;
        [self.contentView addSubview:name];
        
        UIImageView *vip = [[UIImageView alloc] initWithFrame:CGRectMake(250, 0, 20, 20)];
        self.iv_vip = vip;
        [self.contentView addSubview:vip];
        
        UILabel *content = [[UILabel alloc] init];
        self.lb_content = content;
        content.numberOfLines = 0;
        content.font = [UIFont systemFontOfSize:14];
        content.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:content];
        
        
        UIImageView *picture = [[UIImageView alloc] init];
        self.iv_picture = picture;
        [self.contentView addSubview:picture];
    }
    return self;
}

- (void)setMicroModel:(MicroBlogModel *)microModel
{
    NSLog(@"-----------%@",microModel.icon);
    self.iv_icon.image = [UIImage imageNamed:microModel.icon];
    [self.lb_name setFrame:CGRectMake(80, 0, 90, 30)];
    self.lb_name.text = microModel.name;
    NSLog(@"m------------%@",microModel.vip);
    if([microModel.vip isEqualToString:@"1"])
    {
        [self.iv_vip setHidden:NO];
        [self.iv_vip setImage:[UIImage imageNamed:@"vip.png"]];
    }
    else
    {
        [self.iv_vip setHidden:YES];
    }
        
    
    [self.lb_content setFrame:CGRectMake(10, 70, 300, microModel.contentH)];
    [self.lb_content setText:microModel.content];
}
@end
